[BACKEND] Added request IDs to structured validation and server error payloads consistently #568#618
Conversation
ca31a4d to
e65a820
Compare
utksh1
left a comment
There was a problem hiding this comment.
Thanks for adding request-id error payload coverage. I cannot merge this as written because it changes the global backend test runner behavior in a dangerous way.
testing/backend/conftest.py adds pytest_sessionfinish() with os._exit(exitstatus). That forcibly terminates the Python process after the test session and bypasses normal pytest/plugin teardown, coverage/report writing, fixture cleanup, and any pending async cleanup. This is especially risky as a global test-suite hook and is unrelated to the request-id error contract.
Please remove the forced os._exit() hook and keep this PR focused on the application error payload behavior and tests. If there is a Windows hang, handle it separately with a targeted fixture/resource cleanup fix.
utksh1
left a comment
There was a problem hiding this comment.
Re-reviewed the latest update. The tests now exercise real project/plugin infrastructure instead of local-only fixtures, the previous blocker has been addressed, and checks are green. Approving for merge.
utksh1
left a comment
There was a problem hiding this comment.
The earlier os._exit blocker is fixed, but after #629 merged this branch now conflicts with main because it carries the same CI baseline files. Please rebase on latest main and keep the PR scoped to request-id error payload contract changes/tests; then request review again.
a07ab69 to
08ad973
Compare
|
Sir, I've addressed the changes requested and resolved the merge conflicts. |
Closes #568
Description
This PR addresses backend consistency for error payloads by ensuring that all structured validation (422) and server error responses (HTTPException and manual JSONResponses) include the current request ID.
Key changes include:
RequestValidationErrorandStarletteHTTPExceptioninbackend/secuscan/main.py. This ensures that all unhandled HTTP and request validation exceptions returnrequest_idtop-level alongsidedetail.request_idto the manualJSONResponseconstructed in_report_generation_error_responseinsidebackend/secuscan/routes.py.test_key_file_permissionsintesting/backend/unit/test_api_auth.pyby making the permission assertion platform-aware (chmod behaves differently on Windows).pytest_sessionfinishhook intesting/backend/conftest.pyto forcefully terminate pytest at exit status, preventing event loop/thread hangs on Windows hosts.Type of Change
How Has This Been Tested?
We verified these changes by running the full unit test suite on a Windows host.
python -m pytest testing/backend/unitrequest_idmapping.request_idmapping.request_idmapping.X-Request-IDround-trip verification.Checklist